<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>编辑栏目</title>
    <link rel="stylesheet" href="__PEAR__/component/pear/css/pear.css" />
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">

                  <div class="layui-form-item ">
                  	<div class="layui-col-md6">
					    <label class="layui-form-label">上级栏目</label>
					    <div class="layui-input-inline">
					      <select name="txtParentno">
									<option value="">{$tree['title']}</option>
									{volist name="tree['children']" id="vo"}
									<option {if condition="$vo['id'] eq $one['parent_id'] OR $parent eq $vo['id']"} selected="selected"{/if} value="{$vo['id']}">&nbsp;&nbsp;{$vo['title']}</option>
										{volist name="vo['children']" id="cvo"}
											<option {if condition="$cvo['id'] eq $one['parent_id'] OR $parent eq $cvo['id']"} selected="selected"{/if} value="{$cvo['id']}">&nbsp;&nbsp;&nbsp;&nbsp;{$cvo['title']}</option>
										{/volist}
									{/volist}
							</select>
					    </div>
				    </div>
				    <div class="layui-col-md6">
					    <label class="layui-form-label">栏目模型</label>
					    <div class="layui-input-inline">
					      <select name="sltModel" lay-verify="">
									<option value="">请选择模型</option>
									{volist name="models" id="vo"}
									<option {if condition="$vo['model_id'] eq $one['model_id']"} selected="selected"{/if} value="{$vo['model_id']}">{$vo['model_name']}</option>
									{/volist}
							</select>
					    </div>
				    </div>
				  </div>
				  
				  <div class="layui-form-item">
				  <div class="layui-col-md6">
				    <label class="layui-form-label">栏目名称</label>
				    <div class="layui-input-inline">
				      <input type="text" name="txtChannelName" value="{$one['channel_name']}" required  lay-verify="required" placeholder="请输入代码名称" autocomplete="off" class="layui-input">
				    </div>
				    </div>
				    
				    <div class="layui-col-md6">
				    <label class="layui-form-label">外部链接</label>
				    <div class="layui-input-inline">
				      <input type="text" name="txtLink" value="{$one['link']}" autocomplete="off" class="layui-input">
				    </div>
				    </div>
				  </div>
				  
				  <div class="layui-form-item">
				  <div class="layui-col-md6">
				    <label class="layui-form-label">Meta标题</label>
				    <div class="layui-input-inline">
				      <input type="text" name="txtTitle" value="{$one['title']}" required  lay-verify="required" placeholder="请输入代码名称" autocomplete="off" class="layui-input">
				    </div>
				    </div>
				    
				    <div class="layui-col-md6">
				    <label class="layui-form-label">Meta关键词</label>
				    <div class="layui-input-inline">
				      <input type="text" name="txtKeywords" value="{$one['keywords']}" required  lay-verify="required" placeholder="请输入代码名称" autocomplete="off" class="layui-input">
				    </div>
				    </div>
				  </div>
				  
				  <div class="layui-form-item">
				   <div class="layui-col-md6">
				   	<label class="layui-form-label">Meta描述</label>
				   </div>
					<div class="layui-col-md6">
						<textarea name="txtDescription" placeholder="" class="layui-textarea" style="width:500px;">{$one['description']}</textarea>
					</div>
				  </div>
				  
				  <div class="layui-form-item">
				  <div class="layui-col-md6">
				    <label class="layui-form-label">排列顺序</label>
				    <div class="layui-input-inline">
				      <input type="text" name="txtPriority" value="{$one['priority']}" autocomplete="off" class="layui-input">
				    </div>
				    </div>
				    
				    <div class="layui-col-md6">
				    <label class="layui-form-label">是否显示</label>
				    <div class="layui-input-inline">
				      <input type="radio" name="display" {if condition="$one['is_display'] eq 1"} checked="checked"{/if} value="1" title="是" >
						<input type="radio" name="display" value="0" {if condition="$one['is_display'] eq 0"} checked="checked"{/if} title="否">
				    </div>
				    </div>
				  </div>
				  
				  
				  <input name="option" type="hidden" value="{$option}"/>
				  <input name="txtChannelno" type="hidden" value="{$one['channel_id']}"/>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="type-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script src="__STATIC__/lib/layui/layui.js"></script>
<script src="__PEAR__/component/pear/pear.js"></script>
<script>
layui.use(['form','jquery'],function(){
    let form = layui.form;
    let $ = layui.jquery;
    var path="/{$MODULE_NAME}/portal/channel";
	var _url="/save";
	var tree_path="/{$MODULE_NAME}/portal/Jsondata/getChannels";
    form.on('submit(type-save)', function(data){
        $.ajax({
            url:path+_url,
            data:JSON.stringify(data.field),
            dataType:'json',
            contentType:'application/json',
            type:'post',
            success:function(result){
                if(result.code){
                    layer.msg(result.msg,{icon:1,time:1000},function(){
                        parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                        parent.layui.table.reload("channel-table",{
							where:{'parent':'{$parent}'}
						});
                        var treeHeight=parent.getParentWinHeight($)-25;
                        parent.rebuildTree(parent.layui.dtree,"channelTree",tree_path,treeHeight);
                    });
                }else{
                    layer.msg(result.msg,{icon:2,time:1000});
                }
            }
        })
        return false;
    });
})
</script>
<script>
</script>
</body>
</html>